<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/wesite/view/common/base.jsp"%>
<!doctype html>
<html style="background: #F8F8F8">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>重设密码</title>
    <%@ include file="/wesite/view/common/common.jsp"%>
    <style type="text/css">
        html,body{
            background:#fff;
        }
        .loginbox.modification-pwd{
            margin:0;
        }
        .input-border{
            border-top: 1px solid #F2F2F2;
            border-bottom: 1px solid #F2F2F2;
        }
        .buttom{
            font-size: 1.013333rem;
            background: grey;
            border: none;
            width: 18.93333rem;
            margin: 1.066667rem auto .533333rem auto;
            height: 2.4rem;
            display: block;
            line-height: 2.4rem;
            color: #fff;
            border-radius: 3px;
            -webkit-border-radius: 3px;
            -webkit-appearance: none;
            outline: none;
        }
    </style>
</head>
<body style="background-color: #F8F8F8;">
   <div class="loginbox modification-pwd">
        <div class="login-input input-border">
            <div class="input-text">
                <label>账号</label>
                <input name="" value="${phone}" class="inp-left" type="text" >
            </div>
            <div class="itemTip"></div>
            <div class="input-text" style="border-bottom: none;">
                <label>登录密码</label>
                <input  name="oldpwd" class="text inp-left" type="password" placeholder="填写登录密码">
            </div>
            <div class="itemTip"></div>
        </div>
       <p class="" style="padding:30px 0 5px 15px;background-color: #F8F8F8;color: #999;">请重新设置登录密码</p>
       <div class="login-input input-border" style="margin-top: 0rem">
           <div class="input-text">
               <label>设置密码</label>
               <input name="newpwd" class="inp-left" type="password" placeholder="6-12位数字,字母组合">
           </div>
           <div class="itemTip"></div>
           <div class="input-text" style="border-bottom: none;">
               <label>确认密码</label>
               <input  name="pwd2" class="text inp-left" type="password" placeholder="再次填写密码">
           </div>
           <div class="itemTip"></div>
       </div>
    </div>
   <input type="button" class="buttom" onclick="tonext()" value="确认修改">
   <script src="${webctx}/script/aui-toast.js"></script>
</body>

</html>

<script>
    function tonext(){
        var checked=true;
        var toast = new auiToast({})
        if ($("[name='oldpwd']").val() == ''){
            toast.fail({
                title:"请输入原始密码",
                duration:1000
            })
            checked=false;
        }
        <%--if ($("[name='oldpwd']").val() != ${loginpwd}){--%>
            <%--toast.fail({--%>
                <%--title:"原始密码错误",--%>
                <%--duration:1000--%>
            <%--})--%>
            <%--checked=false;--%>
        <%--}--%>
        if($("[name='newpwd']").val()==''){
            toast.fail({
                title:"请输入新密码",
                duration:1000
            })
            checked=false;
        }
        if($("[name='newpwd']").val().length<6){
            toast.fail({
                title:"至少输入6位密码",
                duration:1000
            })
            checked=false;
        }
        if($("[name='newpwd']").val().length > 16){
            toast.fail({
                title:"密码不能大于16位",
                duration:1000
            })
            checked=false;
        }
        if($("[name='pwd2']").val().length>16){
            toast.fail({
                title:"密码不能低于6位",
                duration:1000
            })
            checked=false;
        }
        if($("[name='pwd2']").val()!=$("[name='newpwd']").val()){
            toast.fail({
                title:"请再一次输入密码",
                duration:1000
            })
            checked=false;
        }
        if(checked){
            $w.httpRequest({
                url:"${ctx}/we/user/wechangepwd",
                data:{"oldpwd":$("[name='oldpwd']").val(),"newpwd":$("[name='newpwd']").val()},
                ok:function(ret){
                    toast.success({
                        title:"密码修改成功",
                        duration:1000
                    });
                   window.location.href="${ctx}/we/user/wehome"
                },fail:function(ret){
                    toast.fail({
                        title:ret.MsgDesc,
                        duration:1000
                    })
                   // $("[name='oldpwd']").parent().next().text(ret.MsgDesc);
                    return false;
                }
            })
        }
    }

</script>